package com.example.yilu1;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ImageButton;
import android.widget.TextView;

public class UserInfoActivity extends AppCompatActivity {
    static public User user;

    private ImageButton userImageButton;
    private TextView userNameTextView,userIdTextView,userRemarksTextView,
                    taobaoTextView,jdTextView,suningTextView,pddTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_user_info);
        ActionBar actionBar=getSupportActionBar();
        actionBar.hide();
        user=new User();
        userImageButton=(ImageButton)findViewById(R.id.user_image_button);
        userNameTextView=(TextView)findViewById(R.id.user_name_text_view);
        userIdTextView=(TextView)findViewById(R.id.user_id_text_view);
        userRemarksTextView=(TextView)findViewById(R.id.user_remarks_text_view);
        taobaoTextView=(TextView)findViewById(R.id.taobao_text_view);
        jdTextView=(TextView)findViewById(R.id.jd_text_view);
        suningTextView=(TextView)findViewById(R.id.suning_text_view);
        pddTextView=(TextView)findViewById(R.id.pdd_text_view);

        updateUserInfo();
    }

    private void updateUserInfo(){
        userImageButton.setImageResource(user.getImageId());
        userNameTextView.setText(user.getName());
        userIdTextView.setText(user.getId());
        userRemarksTextView.setText(user.getRemarks());

        if(user.getTaobaoId().equals("")) taobaoTextView.setText("未登录");
        else taobaoTextView.setText(user.getTaobaoId());
        if(user.getJdId().equals("")) jdTextView.setText("未登录");
        else jdTextView.setText(user.getJdId());
        if(user.getSuningId().equals("")) suningTextView.setText("未登录");
        else suningTextView.setText(user.getSuningId());
        if(user.getPddId().equals("")) pddTextView.setText("未登录");
        else pddTextView.setText(user.getPddId());
    }
}
